#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define ll long long
using namespace std;
const int mod = 1e9+7;
const int maxn = 1e5+10;
ll a[maxn];
ll b[maxn];
void init()
{
	a[0] = 0;
	b[0] = 0;
	for(int i = 1;i<maxn;i++)
	{
		a[i]=(a[i-1]+i*(i+1)/2)%mod;
		b[i] = (b[i-1]+a[i])%mod;
	}
}
int main()
{
	int t,cnt=0;
	init();
	scanf("%d",&t);
	while(t--)
	{
		int n,m;
		scanf("%d %d",&n,&m);
		n = n-2;
		m = m-2;
		if(n<=0||m<=0) printf("Case %d: 0\n",++cnt);
		else 
		{
			ll ans;
			ans = (b[n]*b[m])%mod;
			printf("Case %d: %lld\n",++cnt,ans);
		}
	}
} 
